/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Deviant
 */
@Entity
@Table(name = "function", catalog = "mysweethome", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Function.findAll", query = "SELECT f FROM Function f"),
    @NamedQuery(name = "Function.findByFunctionId", query = "SELECT f FROM Function f WHERE f.functionId = :functionId"),
    @NamedQuery(name = "Function.findByFunctionname", query = "SELECT f FROM Function f WHERE f.functionname = :functionname"),
    @NamedQuery(name = "Function.findByUrl", query = "SELECT f FROM Function f WHERE f.url = :url")})
public class Function implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "function_id", nullable = false)
    private Integer functionId;
    @Size(max = 50)
    @Column(name = "functionname", length = 50)
    private String functionname;
    @Size(max = 50)
    @Column(name = "url", length = 50)
    private String url;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "functionid")
    private Collection<Functionrole> functionroleCollection;

    public Function() {
    }

    public Function(Integer functionId) {
        this.functionId = functionId;
    }

    public Integer getFunctionId() {
        return functionId;
    }

    public void setFunctionId(Integer functionId) {
        this.functionId = functionId;
    }

    public String getFunctionname() {
        return functionname;
    }

    public void setFunctionname(String functionname) {
        this.functionname = functionname;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @XmlTransient
    public Collection<Functionrole> getFunctionroleCollection() {
        return functionroleCollection;
    }

    public void setFunctionroleCollection(Collection<Functionrole> functionroleCollection) {
        this.functionroleCollection = functionroleCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (functionId != null ? functionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Function)) {
            return false;
        }
        Function other = (Function) object;
        if ((this.functionId == null && other.functionId != null) || (this.functionId != null && !this.functionId.equals(other.functionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "app.entity.Function[ functionId=" + functionId + " ]";
    }
    
}
